package com.mxdx.edu.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.mxdx.edu.common.CommonUtils;
import com.mxdx.edu.enums.CmsIdEnums;
import com.mxdx.edu.enums.DisplayTypeEnums;
import com.mxdx.edu.service.ICmsCategoryService;

/**
 * 继续教育-考试群落
 * 
 * @author WangYuan
 * @date 2018-02-12
 *
 */

@Controller
@RequestMapping("/continuingEducation")
public class ExaminationGroupController extends BaseController{

	@Resource
	private ICmsCategoryService cmsCategoryService;
	
	@SuppressWarnings("unchecked")
	@RequestMapping(value = "/auth/examinationGroup")
	public ModelAndView index(HttpServletRequest request,
			HttpServletResponse response) {
		ModelAndView result = new ModelAndView("h5/kaoshiqunluo");
		
		Map<String, Object> param = new HashMap<>();
        int num = 0;
		param.put("begin", num);
		param.put("endNum", 4);
		
		param.put("name", CmsIdEnums.KSQL.getCode());
		param.put("displayType", DisplayTypeEnums.TEXT.getCode());
        List<Map<String, Object>> list = cmsCategoryService.findListByMap(param);
		
		String token = sessionUtil.getTokenSession(request);
		Map<String,Object> studentMap = (Map<String, Object>)redisUtil.get(token);
		String mood = CommonUtils.getStrValueFromMap(studentMap, "mood", "");
		String studentName = CommonUtils.getStrValueFromMap(studentMap, "studentName", "");
		String headPortrait = CommonUtils.getStrValueFromMap(studentMap, "headPortrait", "");
		result.addObject("list", list);
		result.addObject("mood", mood);
		result.addObject("studentName", studentName);
		result.addObject("headPortrait", headPortrait);
		return result;
	}

}
